﻿using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls.Primitives;

namespace Padsurface.App.UserControls
{
    /// <summary>
    /// ToggleButton is unreliable out of the box, this ensures states is properly set
    /// </summary>
    public class AppBarToggleButton : ToggleButton
    {
        public AppBarToggleButton()
        {
            this.Checked += StateChanged;
            this.Unchecked += StateChanged;
        }

        private void StateChanged(object sender, RoutedEventArgs e)
        {
            VisualStateManager.GoToState(this, IsChecked == true ? "Checked" : "Unchecked", false);
        }
    }
}